From 24195b5c4b3afedec9a6aa87288ab58bc0bc54f4 Mon Sep 17 00:00:00 2001 From: Robert Lipe Date: Fri, 30 Jun 2017 12:28:30 -0500 Subject: [PATCH] Make IGC reader more robust on nonsense input. --- igc.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/igc.cc b/igc.cc index 449a75117..a501363c2 100644 --- a/igc.cc +++ b/igc.cc @@ -170,7 +170,7 @@ static void igc_task_rec(const char* rec) // First task record identifies the task to follow if (id == state) { task_desc[0] = '\0'; - if (sscanf(rec, "C%2u%2u%2u%2u%2u%2u%6[0-9]%4c%2u%[^\r]\r\n", + if (sscanf(rec, "C%2u%2u%2u%2u%2u%2u%6[0-9]%4c%2u%79[^\r]\r\n", &tm.tm_mday, &tm.tm_mon, &tm.tm_year, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, flight_date, task_num, &num_tp, task_desc) < 9) { @@ -187,15 +187,14 @@ static void igc_task_rec(const char* rec) // Create a route to store the task data in. rte_head = route_head_alloc(); rte_head->rte_name = task_num; - sprintf(tmp_str, DATEMAGIC "%s: %s", flight_date, task_desc); - rte_head->rte_desc = tmp_str; + rte_head->rte_desc = QStringLiteral(DATEMAGIC) + flight_date + QStringLiteral(": ") + task_desc; route_add_head(rte_head); state++; return; } // Get the waypoint tmp_str[0] = '\0'; - if (sscanf(rec, "C%2u%2u%3u%1[NS]%3u%2u%3u%1[WE]%[^\r]\r\n", + if (sscanf(rec, "C%2u%2u%3u%1[NS]%3u%2u%3u%1[WE]%79[^\r]\r\n", &lat_deg, &lat_min, &lat_frac, lat_hemi, &lon_deg, &lon_min, &lon_frac, lon_hemi, tmp_str) < 8) { fatal(MYNAME ": task waypoint (C) record parse error\n%s", rec); -- 2.30.2